home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 59454 / 59454.xpi / content / Bubble.js next >
Text File  |  2010-01-25  |  3KB  |  100 lines

  1.  
  2. BartUniversalSearch.BubbleClass = BartUtils.defineClass(
  3. {
  4.     name: "UniversalSearchBubbleClass",
  5.     construct: function()
  6.                 {
  7.                     this.bubble = null;
  8.                     this.bubbleId = "UniversalSearchContextBubbleId";
  9.                 },
  10.     methods:
  11.     {
  12.         _createElement: function(doc, name, cssClass)
  13.         {
  14.             var e = doc.createElement(name);
  15.             
  16.             if(cssClass)
  17.             {
  18.                 //e.setAttribute("style", cssClass);
  19.                 e.setAttribute("class", cssClass);
  20.             }
  21.  
  22.             return e;
  23.         },
  24.  
  25.         removeBubble: function()
  26.         {
  27.             if(this.bubble)
  28.             {
  29.                 var doc = this.bubble.ownerDocument;
  30.                 var bubble;
  31.                 do
  32.                 {
  33.                     bubble = doc.getElementById(this.bubbleId);
  34.                     if(bubble)
  35.                         bubble.parentNode.removeChild(bubble);
  36.                 } while(bubble != null);
  37.  
  38.                 this.bubble = null;
  39.             }
  40.         },
  41.  
  42.         getBubble: function()
  43.         {
  44.             return this.bubble;
  45.         },
  46.  
  47.         createBubble: function(doc, icons)
  48.         {
  49.             this.removeBubble();
  50.             
  51.             var root = this._createElement(doc, "span", "universalsearch-bubble");
  52.  
  53.             var inner = "";
  54.             inner += "<span class=\"universalsearch-bubble-body\" onmouseover=\"this.parentNode.style.MozOpacity=1; if(this.parentNode.filters && this.parentNode.filters.alpha) this.parentNode.filters.alpha.opacity=100;\" "
  55.             + " onmouseout=\"this.parentNode.style.MozOpacity=0.6;if(this.parentNode.filters && this.parentNode.filters.alpha) this.parentNode.filters.alpha.opacity==60;\""
  56.             + " onselectstart=\"return false;\" ondragstart=\"return false;\">";
  57.             inner += "<span class=\"universalsearch-bubble-iconframe\">";
  58.             for(var i = 0; i < icons.length; i++)
  59.             {
  60.                 inner += icons[i];
  61.             }
  62.  
  63.             inner += "</span></span>";
  64.             root.innerHTML = inner;
  65.  
  66.             this.bubble = root;
  67.             this.bubble.setAttribute("id", this.bubbleId);
  68.  
  69.             return root;
  70.         },
  71.  
  72.         /**
  73.          * Generate an HTML element htmlText, which is a <a> element with an <img> child element.
  74.          * Every parameter should be an associative array.
  75.          */
  76.         createIcon: function(imgProps, linkProps)
  77.         {
  78.             var a = "<a ";
  79.             var p;
  80.             for(p in linkProps)
  81.             {
  82.                 a += p;
  83.                 a += "=\"" + linkProps[p] + "\" ";
  84.             }
  85.             a += "><img ";
  86.             for(p in imgProps)
  87.             {
  88.                 a += p;
  89.                 a += "=\"" + imgProps[p] + "\" ";
  90.             }
  91.             a += " /></a>";
  92.  
  93.             return a;
  94.         }
  95.     },
  96.  
  97.     statics:
  98.     {
  99.     }
  100. });